<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>修改部门</title>
	<%@ include file="/common/common_style_script.jsp"%>
</head>
<body>
    <form id="formEdit" action="<c:url value="/sys/dept/doUpdate.action"/>" 
    	class="cf wd5 fl" target="_top">
        <div>
            <label for="deptId">部门编号</label>
            <input id="deptId" name="dept.deptId" value="<c:out value="${dept.deptId}"/>" readonly="readonly"/>
            <label for="deptName">部门名称</label>
            <input id="deptName" name="dept.deptName" value="<c:out value="${dept.deptName}"/>" />
        </div>
        <div>
        	<label for="superDept">上级部门</label>
        	<s:select id="superDept" name="dept.superDept.deptId" list="deptList" listKey="deptId" listValue="deptName" headerKey="-1" headerValue="-- 请选择 --" value="dept.superDept.deptId"></s:select>
            <label for="deptManager">部门负责人</label>
            <s:select id="deptManager" name="dept.deptManager.employeeId" list="employeeList" listKey="employeeId" listValue="employeeName" headerKey="-1" headerValue="-- 请选择 --" value="dept.deptManager.employeeId"></s:select>
        </div>
        <div>
        	<label for="deptDesc">部门描述</label>
            <textarea id="deptDesc" name="dept.deptDesc" cols="100"><c:out value="${dept.deptDesc}" /></textarea>
        </div>
        <div class="btn">
            <input id="btnSave" type="button" value="保存"/>
            <input id="btnCancel" type="button" value="取消"/>
        </div>
    </form>
</body>
<script>
$(function(){
	$("#btnSave").click(function(){
		//$("#formEdit").submit();
		var params = $('#formEdit').serialize();
		$.ajax({
			type:'POST',
			dataType:'json',
			url:'<c:url value="/ajax/dept/doUpdate.action"/>',
			data:params,
			success:function(data){
				if(data.success) {
					alert('保存成功');
					var id = data.id;
					parent.frames['left'].location.reload();
					location.href = '<c:url value="/sys/dept/toAction/view.action?id="/>' + id;
				} else {
					alert('操作失败，原因：' + result.exception);
				}
			}
		});
	});
	$("#btnCancel").click(function(){
		history.go(-1);
	});
});
</script>
</html>